package cc.idoone.spring_boot_hello.actuator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 自定义 metrics 服务
 *
 * @author hemj
 * @since 2017/10/18
 */
@RestController
@RequestMapping("/metrics")
public class MetricsDemoController {
	@Autowired
	private CounterService counterService;
	@Autowired
	private GaugeService gaugeService;

	@RequestMapping("/greet")
	public String greet() {
		counterService.increment("myapp.greet.count");
		gaugeService.submit("myapp.greet.num", 100.0);
		return "Hello!";
	}
}
